<template>
  <div class="contain">
    <div class="model">
      <div class="title">
        <div class="tip">
          <span>{{ title }}</span>
        </div>
        <div class="viewMore">
          <router-link :to="linkTo">
            查看更多<i class="el-icon-arrow-right"></i>
          </router-link>
        </div>
      </div>
      <div class="list-contain">
        <ul class="clearFix">
          <li
            v-for="(item, index) in list"
            :key="index"
            :style="{
              width: rowType == '1' ? '100%' : '50%',
              'margin-bottom': marginBottomLi(index)
            }"
          >
            <router-link to="">
              <span class="">{{ item.title }}</span>
              <span class="time">{{ item.time }}</span>
            </router-link>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    linkTo: {
      type: String,
      default: () => ""
    },
    title: {
      type: String,
      default: () => ""
    },
    rowType: {
      type: [String, Number],
      default: () => 1
    },
    list: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    marginBottomLi() {
      return index => {
        const ind = index + 1;
        let bottom = "40px";
        if (this.rowType == "2") {
          if (this.list.length % 2 != 0) {
            bottom = ind == this.list.length ? "0" : "40px";
          } else {
            bottom =
              ind == this.list.length || ind == this.list.length - 1
                ? "0"
                : "40px";
          }
        }
        return bottom;
      };
    }
  }
};
</script>

<style scoped lang="scss">
.contain {
  .model {
    > .title {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      .tip {
        width: 225px;
        height: 61px;
        background-image: url("../../../assets/images/jkq/tipTitle.svg");
        background-size: cover;
        background-repeat: no-repeat;
        color: #ffffff;
        font-size: 22px;
        span {
          width: 220px;
          height: 53px;
          display: flex;
          justify-content: center;
          align-items: center;
        }
      }
      .viewMore {
        color: #999999;
        a {
          color: inherit;
        }
        i {
          color: #e5e5e5;
        }
      }
    }
    .list-contain {
      background-color: #fafafa;
      ul {
        padding: 43px 0 43px 0;
        li {
          float: left;
          font-size: 18px;
          color: #333333;
          &:last-child {
            margin-bottom: 0;
          }
          a {
            padding: 0 40px 0 72px;
            position: relative;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-family: inherit;
            color: inherit;
            font-size: inherit;
            &:hover {
              color: $font-color;
              &::before {
                background-color: $font-color;
              }
            }
            &::before {
              content: " ";
              width: 10px;
              height: 10px;
              background-color: #eaeaea;
              position: absolute;
              left: 40px;
              top: 50%;
              transform: translateY(-50%);
              border-radius: 50%;
            }
          }
        }
      }
    }
  }
}
</style>
